pluginHome = new File( grailsSettings.projectPluginsDir.path ).listFiles().find { it.name.startsWith('cloud-tools-') }
if(pluginHome == null) pluginHome = "."

includeTargets << new File( "${pluginHome}/scripts/CloudToolsInit.groovy" )

target('default': "curl") {
	save()
}


target(save: "The implementation task") {
    depends( initCloudToolsService)

    cloudToolsService.withCluster {manager, clusterName, cluster->
        def s3path = System.getProperty("cloudtools.s3.path")
		if(s3path != null){
			cluster.dbSave(s3path)
			event("StatusFinal", ["Save Completed to $s3path"])
		}else{
			event('StatusError', ['You must specify cloudtools.s3.path.  Example:\ngrails -Dcloudtools.s3.path=<path> cloud-tools-db-save'])
		}
    }
}
